﻿CREATE PROCEDURE i18n.ResourceCulture_Insert
(
   @culture VARCHAR(10)
)

AS

	SET NOCOUNT ON

	IF EXISTS (SELECT culture_id FROM i18n.ResourceCultures WHERE culture_code = @culture AND is_default = 1)
		RETURN;
		
	DECLARE @cultureId SMALLINT;
	
	SELECT @cultureId = culture_id 
	FROM i18n.ResourceCultures 
	WHERE culture_code = @culture;

	-- insert all text for this culture
	INSERT INTO i18n.ResourceValues (key_id, culture_id, resource_value, is_translated)
	SELECT key_id, @cultureId, resource_value, 0
	FROM i18n.ResourceValues T
	JOIN i18n.ResourceCultures C
		ON T.culture_id = C.culture_id
		AND C.is_default = 1;

